﻿using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using System.Diagnostics;

namespace Auction_Boxing_2
{
    public class BoxingCane : Melee
    {
        HitBox thisBox;
        public override HitBox ItemHitbox
        {
            get
            {
                return thisBox;
            }
        }


        public override bool isAttacking
        {
            get { return thisBox.Enabled; }

        }

        const int Width = 100;
        const int Height = 60;



        public BoxingCane(float x, float y, int width, int height, BoxingPlayer StatePlayer, Input_Handler input)
        {

            this.Position = new Vector2(x, y);
            ItemAnimPlayer = new AnimationPlayer();
            name = "cane";
            this.Player = StatePlayer;
            //=============================================
            // temporary hitbox AuctionCane needs width and height
            this.thisBox = new HitBox(x, y, Width, Height, StatePlayer, false);
            //=============================================


        }

        public override void LoadContent(ContentManager Content, Item item)
        {
            this.AuctionItem = item;

            thisBox.LoadContent(Content);

            this.health = AuctionItem.health;
            this.stamina = AuctionItem.stamina;
            this.cooldown = AuctionItem.cooldown;
            this.defense = AuctionItem.defense;
            this.attack = AuctionItem.attack;
            this.movement = AuctionItem.movement;

            thisBox.Enabled = false;

            ItemAnimation = new Animation(Content.Load<Texture2D>("BoxingItems/Cane_Attack"), .05f, false, 44);
            ItemAnimPlayer.PlayAnimation(ItemAnimation);
        }



        public override void HandleDirection(SpriteEffects effect)
        {
            thisBox.HandleDirection(effect);

            this.DirEffect = effect;
            if (effect == SpriteEffects.None)
                Direction = DirectionType.Right;
            if (effect == SpriteEffects.FlipHorizontally)
                Direction = DirectionType.Left;
        }

        public override void Update()
        {
            thisBox.Update();

            if (Player.InternalState.isKeyDown(KeyPressed.Attack0))
                thisBox.Enabled = true;
            else
                thisBox.Enabled = false;

            this.Position = new Vector2(Player.Position.X, Player.Position.Y);
        }

        public override void HandleMovement()
        {

        }

        public override void HandleState()
        {
            if (!Player.InternalState.isKeyDown(KeyPressed.Attack0))
                Player.InternalState = new StateMoving(Player.InternalState);

        }

        public override void SetPosition(float x, float y)
        {
            Position = new Vector2(x, y);


        }

        public override void HandleCollosion(List<BoxingPlayer> Players)
        {

        }

        public override void Ability() { }



        public override void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            if (Direction == DirectionType.Right)
                ItemAnimPlayer.Draw(gameTime, spriteBatch, Color.White, Position, 0, Vector2.Zero, 1f, DirEffect);
            if (Direction == DirectionType.Left)
                ItemAnimPlayer.Draw(gameTime, spriteBatch, Color.White, Position, 0, ItemAnimPlayer.Origin, 1f, DirEffect);
            //thisBox.Draw(spriteBatch, gameTime);
        }
    }


}
